const confettiContainer = document.getElementById('confetti');

window.onload = function () {
    const colors = ['#FF5733', '#33FF57', '#3377FF', '#FF33E7', '#77FF33'];
    for (let i = 0; i < 100; i++) {
        const confetti = document.createElement('div');
        confetti.classList.add('confetti-item');
        confetti.style.width = Math.random() * 10 + 5 + 'px';
        confetti.style.height = Math.random() * 10 + 5 + 'px';
        confetti.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
        confetti.style.left = Math.random() * 100 + '%';
        confetti.style.animationDelay = Math.random() * 5 + 's';
        confettiContainer.appendChild(confetti);
    }
};

// 彩带动画关键帧
const confettiFallKeyframes = `
from {
transform: translateY(-100%);
}
to {
transform: translateY(100vh);
}
`;
const style = document.createElement('style');
style.textContent = `
.confetti-item {
animation: confetti-fall 5s ease-out infinite;
}
@keyframes confetti-fall {
${confettiFallKeyframes}
}
`;
document.head.appendChild(style);